    Private Declare Function SetSysColors Lib "User32.dll" (ByVal nChanges As Int32, _
                         ByRef lpSysColor As Int32, ByRef lpColorValues As Int32) As Int32

    Private Declare Function GetSysColor Lib "User32.dll" (ByVal nIndex As Int32) As Int32


    Private Sub SetBackgroundColor(ByVal tempColor As System.Drawing.Color)

        Dim temp As Int32

        temp = SetSysColors(1, 1, RGB(tempColor.R, tempColor.G, tempColor.B)) 'Returns 0 if it can't set the system color

        If temp = 0 Then

            MessageBox.Show("There was an error setting the desktop background color")

        End If

    End Sub


    Private Function GetBackgroundColor() As Color

        Dim tempColor As Int32
        Dim returnColor As Color

        tempColor = GetSysColor(1) 'Get our desktop color, returns 0 if it can't retrieve the color

        If tempColor = 0 Then  ' Couldn't get desktop background

            MessageBox.Show("There was an error getting the desktop background color")
            Return Nothing  ' Exit and return nothing due to error

        Else

            Try
                'Convert our color to RGB
                returnColor = Color.FromArgb(tempColor And &HFF, (tempColor And &HFF00) >> 8, (tempColor And &HFF0000) >> 16)

            Catch ex As Exception
                'There was an error, display it
                MessageBox.Show("Error converting colors: ", ex.Message)

                Return Nothing 'Return nothing due to error

            End Try

            Return returnColor  ' Return our color 

        End If

    End Function